var Urn = AjaxStack.Urn;

YAHOO.namespace("ajaxstack");
YAHOO.ajaxstack.UrnTests = new YAHOO.tool.TestCase({

	name: "Urn Tests",

	//--------------------------------------------- 
	// Setup and tear down 
	//---------------------------------------------

	setUp: function()
	{
	},

	tearDown: function()
	{
	},

	assertUrn: function(urn, resource, name, id)
	{
		Assert.areEqual(resource, urn.getResource());
		Assert.areEqual(name, urn.getName());
		Assert.areEqual(id, urn.getId());
	},

	//--------------------------------------------- 
	// Tests 
	//---------------------------------------------

	testNew: function()
	{
		this.assertUrn(new Urn('res', 'name', 1), 'res', 'name', 1);
		this.assertUrn(new Urn('res', 1), 'res', null, 1);
	},

	testParse: function()
	{
		this.assertUrn(Urn.parse('urn:res:name:1'), 'res', 'name', 1);
		this.assertUrn(Urn.parse('urn:res:1'), 'res', null, 1);
	},

	testStatic: function()
	{
		var urnStr = 'urn:res:name:1';
		Assert.areEqual('res', Urn.getResource(urnStr));
		Assert.areEqual('name', Urn.getName(urnStr));
		Assert.areEqual('1', Urn.getId(urnStr));
		Assert.areSame(1, Urn.getIdNumber(urnStr));
	}

});

